<?php
include 'test_header.php';

class test_db_obj_reply extends UnitTestCase{
	
	private $db ; 

	function setUp(){

		$this->db = db_connect();

		$sql = "
CREATE TABLE IF NOT EXISTS `reply` (
  `reply_no` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `topic_no` bigint(20) NOT NULL,
  `content` text NOT NULL,
  `reply_username` varchar(256) NOT NULL,
  `reply_time` datetime NOT NULL,
  UNIQUE KEY `reply_no` (`reply_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
";

		$res = $this->db->query( $sql );
	}

	function tearDown(){
		
		$sql = "drop table reply";

		$res = $this->db->query( $sql );
	
	}

	function test_save_a_reply(){

		$db_obj_reply = new db_obj_reply( $this->db ) ;
		$db_obj_reply->set( 'topic_no' , '1' );
		$db_obj_reply->set( 'content' , 'test' );
		$db_obj_reply->set( 'reply_username' ,  'tester' );
		$db_obj_reply->set( 'reply_time' , '2000-11-11 22:22:22' );

		$this->assertTrue( $db_obj_reply->save() );
	}
}
	

$test = new test_db_obj_reply();
$test->run( new HtmlReporter() );

